home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
ast_comp
/
cpp-kit.lha
/
c++kit
/
main.C
next >
Wrap
C/C++ Source or Header
|
1993-04-11
|
837b
|
56 lines
#include <iostream.h>
#include "Parse.H"
#include <ctype.h>
int
number(Parse &P, int& value)
{
Token tok;
P, NUMBER(tok);
if( P ) {
int i = isdigit(tok[0])?0:1;
for( value = 0; i < tok.length(); i++ ) {
value = value * 10 + (tok[i] - '0');
}
if( tok[0] == '-' ) {
value = -value;
}
}
return P;
}
int
Break(Parse& P)
{
int fleet;
int amt;
P , 'B', MATCH(number, fleet), MATCH(number, amt), CHOOSE(1),
OR, 'B', "MAX", MATCH(number, amt), CHOOSE(2);
switch(P()) {
case 0: {
cout << "no match" << endl;
break;
}
case 1: {
cout << fleet << ' ' << amt << endl;
break;
}
case 2: {
cout << "MAX " << amt << endl;
break;
}
}
return P;
}
main()
{
Parse P("foo");
Token x;
P, MATCH(Break);
cout << P << ' ' << P() << endl;
}